//
//  BaseTabBarController.m
//  QYer
//
//  Created by lanou on 16/8/5.
//  Copyright © 2016年 CaiZhuYu. All rights reserved.
//

#import "BaseTabBarController.h"
#import "RecommendViewController.h"
#import "DestinationViewController.h"
#import "CommunityViewController.h"
#import "UserViewController.h"

@interface BaseTabBarController ()

@end

@implementation BaseTabBarController

//初始化子视图控制器
- (void)setupChildVC:(UIViewController *)viewController title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage {
    viewController.tabBarItem.title = title;
    viewController.tabBarItem.image = [UIImage imageNamed:image];
    viewController.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage];
    
    UINavigationController *NAVC = [[UINavigationController alloc] initWithRootViewController:viewController];
    [self addChildViewController:NAVC];
}


#pragma mark -----

- (void)viewDidLoad {
    [super viewDidLoad];
    
    /*
    RecommendViewController *recommendVC = [[RecommendViewController alloc] init];
    UINavigationController *recommendNAVC = [[UINavigationController alloc] initWithRootViewController:recommendVC];
    recommendVC.tabBarItem.title = @"推荐";
    recommendVC.tabBarItem.image = [UIImage imageNamed:@"推荐"];
    recommendVC.tabBarItem.selectedImage = [UIImage imageNamed:@"推荐-1"];
    [self addChildViewController:recommendNAVC];
    
    DestinationViewController *destinationVC = [[DestinationViewController alloc] init];
    UINavigationController *destinationNAVC = [[UINavigationController alloc] initWithRootViewController:destinationVC];
    destinationVC.tabBarItem.title = @"目的地";
    destinationVC.tabBarItem.image = [UIImage imageNamed:@"目的地"];
    destinationVC.tabBarItem.selectedImage = [UIImage imageNamed:@"目的地-1"];
    [self addChildViewController:destinationNAVC];
    
    CommunityViewController *communityVC = [[CommunityViewController alloc] init];
    UINavigationController *communityNAVC = [[UINavigationController alloc] initWithRootViewController:communityVC];
    communityVC.tabBarItem.title = @"社区";
    communityVC.tabBarItem.image = [UIImage imageNamed:@"社区"];
    communityVC.tabBarItem.selectedImage = [UIImage imageNamed:@"社区-1"];
    [self addChildViewController:communityNAVC];
    
    UserViewController *userVC = [[UserViewController alloc] init];
    UINavigationController *userNAVC = [[UINavigationController alloc] initWithRootViewController:userVC];
    userVC.tabBarItem.title = @"我的";
    userVC.tabBarItem.image = [UIImage imageNamed:@"我的"];
    userVC.tabBarItem.selectedImage = [UIImage imageNamed:@"我的-1"];
    [self addChildViewController:userNAVC];
    */
    [self setupChildVC:[[RecommendViewController alloc] init] title:@"推荐" image:@"推荐" selectedImage:@"推荐-1"];
    [self setupChildVC:[[DestinationViewController alloc] init] title:@"目的地" image:@"目的地" selectedImage:@"目的地-1"];
    [self setupChildVC:[[CommunityViewController alloc] init] title:@"社区" image:@"社区" selectedImage:@"社区-1"];
    [self setupChildVC:[[UserViewController alloc] init] title:@"我的" image:@"我的" selectedImage:@"我的-1"];
    
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
